#include <iostream>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <set>
#include <unordered_set>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const int N=2e5+10;
ll a[N];

int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		int n,k;
		scanf("%d %d",&n,&k);
		for(int i=1;i<=n;i++) scanf("%lld",a+i);
		sort(a+1,a+1+n); 
		ll sum=0;
		for(int i=1;i<=n-k;i++) sum=sum+a[i];
		
		ll ans=sum;
		for(int i=1;i<=k;i++)
		{
			sum=sum-a[i*2]-a[i*2-1];
			sum+=a[n-k+i];
			ans=max(ans,sum);
		}
		cout<<ans<<endl;

		
	}

	return 0;
}

